package com.shop2cn.iapi.agentproducts.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.http.client.ClientProtocolException;
/**
 * 自动加价  28326862
 * 
 * http://wiki.ymatou.cn:8090/pages/viewpage.action?pageId=28326862
**/
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.SetAutoMarkupBean;
import com.shop2cn.iapi.agentproducts.service.SetAutoMarkupCall;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.SetMarkupConfigBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.SetMarkupConfigCall;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymatou.mq.admin.parameter.MessageListBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.MqQueryCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.utils.TestDataManager;

/**
 * 设置/更新商品使用自动加价价格回调 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_SetAutoMarkup {
	private static SetAutoMarkupBean setautomarkupBean;
	private static SetAutoMarkupCall setautomarkupCall;
	private static YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("设置/更新商品使用自动加价价格回调");
	}

	@Before
	public void caseUp() {
		setautomarkupBean = new SetAutoMarkupBean();
		setautomarkupCall = new SetAutoMarkupCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(setautomarkupCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * 初始化SetMarkupConfigBean
	 * 
	 * @param agentUserId
	 * @param rootUserId
	 * @return
	 */
	private SetMarkupConfigBean initSetMarkupConfigBean(Integer agentUserId, Integer rootUserId) {
		SetMarkupConfigBean setmarkupconfigBean = new SetMarkupConfigBean();
		setmarkupconfigBean.setAgentId(agentUserId);
		setmarkupconfigBean.setSupplierId(Arrays.asList(rootUserId));
		setmarkupconfigBean.setMarkupType(1);
		setmarkupconfigBean.setPercentage(new BigDecimal(10));
		setmarkupconfigBean.setDecimalType(1);
		setmarkupconfigBean.setOnSaleType(1);
		setmarkupconfigBean.setRefreshProduct(true);
		return setmarkupconfigBean;
	}

	/**
	 * 调用
	 * 
	 * @param setmarkupconfigBean
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private void SetMarkupConfig(SetMarkupConfigBean setmarkupconfigBean) throws ClientProtocolException, IOException {
		SetMarkupConfigCall setmarkupconfigCall = new SetMarkupConfigCall();
		setmarkupconfigCall.setData(setmarkupconfigBean);
		setmarkupconfigCall.callService();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SetAutoMarkup_001() {
		Logger.start(true, "供货商设置按比例加价10%,精确到十位,商品计算价格成功-拿货价*10%");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(4);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(10);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(10).setScale(2), p1.setScale(2), "验证价格");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_002() {
		Logger.start(true, "供货商设置按比例加价10%,精确到个位,商品计算价格成功-拿货价*10%");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(1);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(10);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(11).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_003() {
		Logger.start(true, "供货商设置按比例加价10%,精确到小数点1位,商品计算价格成功-拿货价*10%");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(2);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(5);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(5.5).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_004() {
		Logger.start(true, "供货商设置按比例加价10%,精确到小数点2位,商品计算价格成功-拿货价*10%");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(3);
			setmarkupconfigBean.setPercentage(new BigDecimal(15));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(1);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(1.15).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_005() {
		Logger.start(true, "供货商设置按比例加价10%商品价格1.1,精确到个位商品计算价格成功,价格2");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(1);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(1.1);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(2).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_006() {
		Logger.start(true, "供货商设置按比例加价10%商品价格0.01,精确到个位商品计算价格成功,价格1");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(1);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(0.01);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(1).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_007() {
		Logger.start(true, "供货商设置按比例加价10%商品价格1.1,精确到十位商品计算价格成功,价格10");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(4);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(1.1);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(10).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_008() {
		Logger.start(true, "供货商设置按比例加价10%,多个规格商品都计算价格,精确到小数点2位,商品计算价格成功-拿货价*10%");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(3);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(15);
			addAgentProductBean.getCatalogList().get(1).getAgentPriceList().get(0).setAgentPrice(20.5);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(16.5).setScale(2), p1.setScale(2), "验证价格");

			BigDecimal p2 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(1).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(22.55).setScale(2), p2.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_009() {
		Logger.start(true, "供货商设置建议零售价,商品计算价格成功-直销价");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(3);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			setmarkupconfigBean.setMarkupType(2);
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(10);
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(1).setAgentPrice(20);
			// 设置直销价
			addAgentProductBean.getCatalogList().get(0).setDirectPrice(155d);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(155).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_010() {
		Logger.start(true, "供货商设置建议零售价,多个规格商品都计算价格,商品计算价格成功-直销价");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(3);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			setmarkupconfigBean.setMarkupType(2);
			SetMarkupConfig(setmarkupconfigBean);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(15);
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(1).setAgentPrice(20.5);
			addAgentProductBean.getCatalogList().get(0).setDirectPrice(55d);

			addAgentProductBean.getCatalogList().get(1).getAgentPriceList().get(0).setAgentPrice(25);
			addAgentProductBean.getCatalogList().get(1).getAgentPriceList().get(1).setAgentPrice(35);
			addAgentProductBean.getCatalogList().get(1).setDirectPrice(65d);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(55).setScale(2), p1.setScale(2), "验证价格");

			BigDecimal p2 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(1).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(65).setScale(2), p2.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_011() {
		Logger.start(true, "供货商设置建议零售价,商品计算价格成功-不加价=拿货价");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(3);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			setmarkupconfigBean.setMarkupType(3);
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(10);
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(1).setAgentPrice(20);
			// 设置直销价
			addAgentProductBean.getCatalogList().get(0).setDirectPrice(155d);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(10).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_012() {
		Logger.start(true, "供货商设置建议零售价,多个规格商品都计算价格,商品计算价格成功-不加价=拿货价");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(3);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			setmarkupconfigBean.setMarkupType(3);
			SetMarkupConfig(setmarkupconfigBean);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(15);
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(1).setAgentPrice(20.5);
			addAgentProductBean.getCatalogList().get(0).setDirectPrice(55d);

			addAgentProductBean.getCatalogList().get(1).getAgentPriceList().get(0).setAgentPrice(25);
			addAgentProductBean.getCatalogList().get(1).getAgentPriceList().get(1).setAgentPrice(35);
			addAgentProductBean.getCatalogList().get(1).setDirectPrice(65d);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(15).setScale(2), p1.setScale(2), "验证价格");

			BigDecimal p2 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(1).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(25).setScale(2), p2.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_013() {
		Logger.start(true, "供货商设置按比例加价10%,精确到小数点2位,商品计算价格成功-拿货价*10%-计价币种为日元,价格最小单位元");
		try {
			Integer rootUserId = GodmchManageCallService.CreateCountrySellerMch("JPN");
			Integer agentUserId = GodmchManageCallService.createAgent(rootUserId,"JPN");
			// // 创建渠道商
			// CreateCodeBean createAllMsgSellerMch =
			// GodmchManageCallService.CreateAllMsgSellerMch();
			// // 创建渠道商邀请码
			// CreateCodeCall createCodeCall2 =
			// GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// // 创建代理商
			// Integer agentUserId =
			// GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			// int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(3);
			setmarkupconfigBean.setPercentage(new BigDecimal(15));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(1);
			addAgentProductBean.setCurrency("JPY");
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(6000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(1).setScale(2), p1.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_SetAutoMarkup_014() {
		Logger.start(true, "供货商设置按比例加价10%,精确到个位,商品计算价格成功-拿货价*10%-四捨五入");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(1);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(5);
			addAgentProductBean.getCatalogList().get(1).getAgentPriceList().get(0).setAgentPrice(4);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("200", setautomarkupCall.getString("code"), "验证code");
			BigDecimal p1 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(0).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(6).setScale(2), p1.setScale(2), "验证价格");

			BigDecimal p2 = setautomarkupCall.getJsonObject().get("data").getAsJsonObject().get("catalogs").getAsJsonArray().get(1).getAsJsonObject().get("price")
					.getAsBigDecimal();
			Logger.verifyEquals(BigDecimal.valueOf(4).setScale(2), p2.setScale(2), "验证价格");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SetAutoMarkup_015() {
		Logger.start(true, "商品不存在失败");
		try {
			setautomarkupBean.setProductId("p1");
			setautomarkupBean.setUserId(501475647);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("201", setautomarkupCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SetAutoMarkup_016() {
		Logger.start(true, "商户不存在失败");
		try {
			setautomarkupBean.setProductId("p1");
			setautomarkupBean.setUserId(1);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("201", setautomarkupCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SetAutoMarkup_017() {
		Logger.start(true, "只能设置代理价格");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(4);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(10);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			setautomarkupBean.setProductId(productId);
			setautomarkupBean.setUserId(rootUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("201", setautomarkupCall.getString("code"), "验证code");
			//{"code":201,"message":"只能设置代理商品价格 p3717391","bCode":0,"serverTime":"2020-04-09 19:02:31","data":null}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SetAutoMarkup_018() {
		Logger.start(true, "未设置自动加价规则");
		try {
			// 创建渠道商
			CreateCodeBean createAllMsgSellerMch = GodmchManageCallService.CreateAllMsgSellerMch();
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(createAllMsgSellerMch);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = createAllMsgSellerMch.getMchId();
			// 设置自动加价配置
			SetMarkupConfigBean setmarkupconfigBean = initSetMarkupConfigBean(agentUserId, rootUserId);
			setmarkupconfigBean.setDecimalType(4);
			setmarkupconfigBean.setPercentage(new BigDecimal(10));
			SetMarkupConfig(setmarkupconfigBean);
			// 创建单规格商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "autotest", true);
			while (addAgentProductBean.getCatalogList().size() > 1) {
				addAgentProductBean.getCatalogList().remove(0);
			}
			// 设置拿货价 这里的代理所属agenttype默认和第一个关联 所以设置第一个价格
			addAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(10);
			Logger.debug("addAgentProductBean:" + FormatUtil.beanToGSONString(addAgentProductBean));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 查询总线发送自动导入商品消息
			MessageListBean MessageListBean = MqQueryCallService.initImportAgentproduct(productId, rootUserId);
			List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if (joa.size() == 0) {
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele -> {
				Logger.debug(ele.toString());
			});
			// 查询自动导入的商品的信息
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream().filter(x -> x.getAction() == 0)
					.filter(x -> x.getUserId() == agentUserId).collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			

			GodmchManageCallService.DeleteMarketupConfig(agentUserId, rootUserId);
			
			setautomarkupBean.setProductId(ap.get(0).getProductId());
			setautomarkupBean.setUserId(agentUserId);
			setautomarkupCall.setData(setautomarkupBean);
			setautomarkupCall.callService();
			Logger.verifyEquals("201", setautomarkupCall.getString("code"), "验证code");
			//{"code":201,"message":"用户未设置自动加价配置 p3717603","bCode":0,"serverTime":"2020-04-09 19:07:50","data":null}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}